package org.feiye.studyday10;

import java.util.Scanner;

public class Fruit {

	public static void main(String[] args) {
//		String []ar={"桃子","梨子","西瓜","李子","葡萄","菠萝"};

//		从数组中删除一个，指定
//		删除的位置，最后一个置null...
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入删除的序号：");
		int index = sc.nextInt() - 1;// 从1开始
		String[] ar = { "桃子", "梨子", "西瓜", "李子", "葡萄", "菠萝" };
		for (int i = 0; i < ar.length; i++) {
			System.out.println(ar[i]);
		}
		System.out.println("--------------------------------------");
		// 删除
		if (index >= 0 && index < ar.length) {
		for (int i = index; i < ar.length - 1; i++) {
			ar[i] = ar[i + 1];
			}
			ar[ar.length - 1] = null;
		} else {
			System.out.println("序号超范围！！");
		}
		System.out.println("--------------------------------------------");
		for (int i = 0; i < ar.length; i++) {
			System.out.println(ar[i]);
		}
		}
	}


